package hello;

/**
 * Created with IntelliJIDEA.
 * Description:
 * User: ASUS
 * Date: 2025/8/31
 * Time: 17:28
 */
public class Person1 {
    private String name = "无名氏"; // 2. 就地初始化
    private int age; // 1. 默认初始化为 0

    public Person1(String name, int age) {
        // 3. 构造方法执行
        this.name = name; // "无名氏" 被 "张三" 覆盖
        this.age = age;   // 0 被 25 覆盖
    }

    public void display() {
        System.out.println("姓名: " + name + ", 年龄: " + age);
    }

    public static void main(String[] args) {
        Person1 p = new Person1("张三", 25);
        p.display(); // 输出: 姓名: 张三, 年龄: 25
    }
}